﻿using System;
using System.Collections.Generic;

namespace FluentResourceMapping.AutoMapping
{
    public class AutoResourceMappingContainer
    {
        private readonly IList<AutoResourceMappingModel> _mappingModels = new List<AutoResourceMappingModel>();

        public AutoResourceMappingContainer Add(AutoResourceMappingModel autoResourceMappingModel)
        {
            _mappingModels.Add(autoResourceMappingModel);
            return this;
        }

        public AutoResourceMappingContainer Add(Func<AutoResourceMappingModel> autoResourceMappingModel)
        {
            Add(autoResourceMappingModel());
            return this;
        }

        internal void Apply(ResourceMappingModel resourceMappingModel)
        {
            foreach (AutoResourceMappingModel autoResourceMappingModel in _mappingModels)
            {
                resourceMappingModel.AddMapping(autoResourceMappingModel);
            }
        }
    }
}